Apple, the Apple logo, and Macintosh are registered trademarks of Apple Computer, Inc.
Mac and OpenDoc are trademarks of Apple Computer, Inc.
The Uncommon Case
In the simplest case, removing an embedded frame is straightforward. Just follow these steps:
• Remove all facets on the embedded frame.
• Call embeddedFrame->Remove(ev). This also calls Release on the frame, so don't use the reference after this call.
However, this simple case does not allow the deletion to operate with Undo. Which brings us to...
Undoable Frame Deletion
If you follow the above recipe, you will destroy the embedding structure for all parts embedded within the frame being deleted. At the very least this will be a lot of work to Undo, and at the worst you won't be able to reconstruct the hierarchy at all. So you should follow a different recipe if you want to Undo, which you almost certainly do.
• Remove all facets on the embedded frame.
• Set the frame's ContainingFrame to kODNULL. This will close any part window views of this frame, as well as correctly indicate the frame has no containing frame.
• Set the frame's InLimbo flag to kODTrue to indicate that it is not actually embedded anywhere.
• Put the frame aside somewhere, and put a reference to it in the Undo ActionData which you record on the Undo history.
• Remove the frame from your content data structures.
If at some point the user chooses to undo the frame deletion, restoring it can be accomplished like so:
• Get the frame from the undo limbo where you put it, and insert it back into your content data structures.
• Set the embedded frame's InLimbo flag to kODFalse.
• Set the embedded frame's ContainingFrame to your part's display frame (or the correct one if you have more than one).
• If the frame is visible, create a facet for it.
When the part receives a DeleteActionData call, it should commit the action. If the action involves an embedded frame deletion, the deletion should be committed as follows:
• Check the InLibmo flag of the deleted frame. A value of kODFalse will indicate if a frame that was Cut has been Pasted into another containing frame.
• If frame->IsInLimbo(ev) is kODTrue, call frame->Remove (ev), and toss the reference.
• If frame->IsInLimbo(ev) is kODFalse, call frame->Release(ev), and toss the reference.